﻿@{
    ViewData["Title"] = "添加设备布局";
    Layout = "_Edit";
}

@section css{
<style>
    .eq-lay-eq-select {
        width: 150px;
    }
</style>
}

<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-add">
        <input type="hidden" class="input-text" value="@Model.ID" id="id" name="id">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>区域编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.AreaCode" placeholder="" id="area" name="area">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>单元格数：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ColumnCount" placeholder="" id="column" name="column">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>默认颜色：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.DefaultColor" placeholder="" id="color" name="color">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>布局方向：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <span class="select-box">
                    <select class="select" size="1" name="dir-Id" id="dir-Id">
                        <option value="-1">--请选择--</option>
                        @foreach (var item in Model.EquipmentDirections)
                        {
                            if (Model.Direction == item.ID)
                            {
                                <option value="@item.ID" selected>@item.Desception</option>
                            }
                            else
                            {
                                <option value="@item.ID">@item.Desception</option>
                            }
                        }
                    </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>调度设备名称：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <span class="select-box">
                    <select class="select" size="1" name="dispatch-eq-Id" id="dispatch-eq-Id">
                        <option value="0">--请选择--</option>
                        @foreach (var item in Model.DispatchEquipments)
                        {
                            if (Model.EquipmentID + "" == item.EquipmentID)
                            {
                                <option value="@item.EquipmentID" selected>@item.EquipmentName</option>
                            }
                            else
                            {
                                <option value="@item.EquipmentID">@item.EquipmentName</option>
                            }
                        }
                    </select>
                </span>

            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设备布局编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.EquipmentLayoutCode" placeholder="" id="layoutCode" name="layoutCode">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设备布局类型：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <span class="select-box">
                    <select class="select" size="1" name="eq-layout-type-Id" id="eq-layout-type-Id">
                        <option value="0">--请选择--</option>
                        @foreach (var item in Model.EquipmentLayoutTypes)
                        {
                            if (Model.EquipmentLayoutTypeID + "" == item.EquipmentLayoutTypeID)
                            {
                                <option value="@item.EquipmentLayoutTypeID" selected>@item.EquipmentLayoutTypeName</option>
                            }
                            else
                            {
                                <option value="@item.EquipmentLayoutTypeID">@item.EquipmentLayoutTypeName</option>
                            }
                        }
                    </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>X坐标：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.PointX" placeholder="" id="pos-x" name="pos-x">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>Y坐标：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.PointY" placeholder="" id="pos-y" name="pos-y">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>最大高度：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.SizeHeigth" placeholder="" id="max-height" name="max-height">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>最大宽度：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.SizeWidth" placeholder="" id="max-width" name="max-width">
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="button" onclick="submmitData()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

@section javascript{

<script>
    $('.skin-minimal input').iCheck({
         checkboxClass: 'icheckbox-blue',
         radioClass: 'iradio-blue',
         increaseArea: '20%'
     });
     function submmitData(){
         var area=$("#area").val();
         if(area==null||area=="")
         {
            popupAlert('区域号不能为空',2,function(data){layer.close(data);});
           return;
         }
         var column=$("#column").val();
         if(column==null||column=="")
         {
            popupAlert('单元格数',2,function(data){layer.close(data);});
           return;
         }
         var color=$("#color").val();
         if(color==null||color=="")
         {
            popupAlert('默认颜色不能为空',2,function(data){layer.close(data);});
           return;
         }
         var dirId=$("#dir-Id").val();
         if(dirId==null||dirId==""||dirId==-1)
         {
            popupAlert('请选择设备方位',2,function(data){layer.close(data);});
           return;
         }
         var dispatchEqId=$("#dispatch-eq-Id").val();
         if(dispatchEqId==null||dispatchEqId==""||dispatchEqId==0)
         {
            popupAlert('请选择调度设备',2,function(data){layer.close(data);});
           return;
         }
         var layoutCode=$("#layoutCode").val();
         if(layoutCode==null||layoutCode=="")
         {
            popupAlert('设备布局代码不能为空',2,function(data){layer.close(data);});
           return;
         }
         var eqLayoutTypeId=$("#eq-layout-type-Id").val();
         if(eqLayoutTypeId==null||eqLayoutTypeId==""||eqLayoutTypeId==0)
         {
            popupAlert('请选择设备布局类型',2,function(data){layer.close(data);});
           return;
         }
         var PosX=$("#pos-x").val();
         if(PosX==null||PosX=="")
         {
            popupAlert('请设置X坐标',2,function(data){layer.close(data);});
           return;
         }
         var PosY=$("#pos-y").val();
         if(PosY==null||PosY=="")
         {
            popupAlert('请设置Y坐标',2,function(data){layer.close(data);});
           return;
         }
         var maxHeight=$("#max-height").val();
         if(maxHeight==null||maxHeight=="")
         {
            popupAlert('请设置最大高度',2,function(data){layer.close(data);});
           return;
         }
         var maxWidth=$("#max-width").val();
         if(maxWidth==null||maxWidth=="")
         {
            popupAlert('请设置最大宽度',2,function(data){layer.close(data);});
           return;
         }
        SubmitFormForAjax("/equipment/operateequipmentlayout", $("#form-add").serialize(), function (data) {
            if (data.result) {
                    popupAlert('提交成功',1,function(){closePageLayer(true);});
            }else{
                popupAlert(data.message,2,function(data){layer.close(data);});
            }
        },true);
     }
</script>
}